use "scedatapublicver.dta"

putexcel set "scevardescrips050324", replace

tab gsimple, mi
tab gsimple, matcell(cell1)
putexcel B1=("Independent Variables") B4=matrix(cell1) 
putexcel A3=("Gender") A4=("Woman") A5=("Man") A6=("Non-Binary/Other")


tab justw rjustw, mi
tab rjustw, matcell(cell2) 
putexcel B9=matrix(cell2)
putexcel A8=("Race") A9=("White") A10=("Non-White")


tab nstraight, mi
tab nstraight, matcell(cell3) 
putexcel B13=matrix(cell3)
putexcel A12=("Sexual Orientation") A13=("Heterosexual") A14=("Not Heterosexual")

tab educ ceduc, mi
tab ceduc, matcell(cell4)
putexcel B17=matrix(cell4)
putexcel A16=("Level of Education") A17=("High School/GED or less") ///
	A18=("Some College (including Associate's Degree)") ///
	A19=("Bachelor's Degree") A20=("Post-Graduate Degree")
	
tab nati, mi	
tab nati, matcell(cell5)
putexcel B23=matrix(cell5)
putexcel A22=("Nativity") A23=("U.S.-born") A24=("Foreign-born")

tab demo, mi
tab demo, matcell(cell6)
putexcel B27=matrix(cell6)
putexcel A26=("Political Affiliation") A27=("Everything else") A28=("Democrat")

tab nreli, mi
tab reli nreli, mi
tab nreli, matcell(cell7)
putexcel B31=matrix(cell7)
putexcel A30=("Religious Background") A31=("None") A32=("Protestant") ///
	A33=("Catholic") A34=("Other")

tab sc1, mi	
summarize sc1
matrix av1=r(mean)
matrix av11=r(sd)
putexcel B36=matrix(av1) B37=matrix(av11)
putexcel A36=("Average Skin Color Rating with Standard Deviation")

tab year, mi
summarize year
matrix av2=r(mean)
matrix av12=r(sd)
putexcel B39=matrix(av2) B40=matrix(av12)
putexcel A39=("Average Year of Birth with Standard Deviation")

	
tab cpeduc, mi
tab cpeduc, mi matcell(cell8)
putexcel B43=matrix(cell8)
putexcel A42=("Highest Level of Parental Education") A43=("High School/GED or less") ///
	A44=("Some College (including Associate's Degree)") ///
	A45=("Bachelor's Degree") A46=("Post-Graduate Degree") A47=("Missing")
	
tab pnati, mi 
tab pnati, mi matcell(cell9)
putexcel B50=matrix(cell9)
putexcel A49=("Parental Nativity") A50=("Both U.S.-born") ///
	A51=("At least One Foreign-born") ///
	A52=("At least One Parent with Missing Information")
	
//social network and setting

tab dateb, mi
tab dateb, matcell(cell10)
putexcel B55=matrix(cell10)
putexcel A54=("Dated Someone Black") A55=("No") A56=("Yes")

tab netb
tab netb, matcell(cell11)
putexcel B59=matrix(cell11)
putexcel A58=("Predominantly Black Social Network") A59=("No") A60=("Yes")

tab nregion, mi
tab nregion, mi nolab
tab nregion region, mi 
tab nregion, mi matcell(cell12)
putexcel B63=matrix(cell12)
putexcel A62=("Region") A63=("Midwest") A64=("Northeast") A65=("South") ///
	A66=("West") A67=("Missing")

tab blacknlperr, mi
summarize blacknlperr
matrix av3=r(mean)
matrix av13=r(sd)
putexcel B69=matrix(av3) B70=matrix(av13)
putexcel A69=("Average Percentage of Black Population in Area with Standard Deviation")
putexcel A71=("Missing") B71=("5")


tab MCTYPE1, mi
tab MCTYPE1, mi nolab
recode MCTYPE1 (1/6 = 0) (0 = 1), gen(nonnaive)
tab MCTYPE1 nonnaive, mi
tab nonnaive, matcell(cell13)
putexcel B74=matrix(cell13)
putexcel A73=("Awareness of Purpose of Study") A74=("No") A75=("Yes")

tab correctno, mi
tab correctno, matcell(cell14)
putexcel B78=matrix(cell14)
putexcel A77=("Identified Correct Number of Profiles") A78=("No") A79=("Yes")

tab nbatch, mi
tab nbatch, nolab
tab nbatch, matcell(cell15)
putexcel B82=matrix(cell15)
putexcel A81=("Batch") A82=("First") A83=("Second")

local lvars1 F1L1 F1M1 F1D1 F3L1 F3M1 F3D1 F5L1 F5M1 F5D1 M3L1 M3M1 M3D1 ///
	M5L1 M5M1 M5D1 M6L1 M6M1 M6D1  ///
	F1L2 F1M2 F1D2 F3L2 F3M2 F3D2 F5L2 F5M2 F5D2 M3L2 M3M2 M3D2 ///
	M5L2 M5M2 M5D2 M6L2 M6M2 M6D2 ///  
	F1L3 F1M3 F1D3 F3L3 F3M3 F3D3 F5L3 F5M3 F5D3 M3L3 M3M3 M3D3 ///
	M5L3 M5M3 M5D3 M6L3 M6M3 M6D3   
foreach var of local lvars1 {
	gen `var'r = 6-`var'
	display in smcl as text "`var'"
	tab `var' `var'r, mi
}


putexcel set "sceoutcomesdescrips050324", replace

putexcel A1=("Ratings by Person, Shade, and Question (Women)")
putexcel B2=("Question 1")

tab F1L1r
tab F1L1r, matcell(cell1)
putexcel C3=("Woman 1")
putexcel B4=("Light") B5=matrix(cell1)
putexcel A5=("Very unlikely") A6=("Somewhat unlikely") A7=("Neutral") ///
	A8=("Somewhatlikely") A9=("Very likely")

tab F1M1r
tab F1M1r, matcell(cell2)
putexcel C4=("Medium") C5=matrix(cell2)

tab F1D1r
tab F1D1r, matcell(cell3)
putexcel D4=("Dark") D5=matrix(cell3)

putexcel F3=("Woman 2")

tab F3L1r
tab F3L1r, matcell(cell4)
putexcel E4=("Light") E5=matrix(cell4)

tab F3M1r
tab F3M1r, matcell(cell5)
putexcel F4=("Medium") F5=matrix(cell5)

tab F3D1r
tab F3D1r, matcell(cell6)
putexcel G4=("Dark") G5=matrix(cell6)

putexcel I3=("Woman 3")

tab F5L1r
tab F5L1r, matcell(cell7)
putexcel H4=("Light") H5=matrix(cell7)

tab F5M1r
tab F5M1r, matcell(cell8)
putexcel I4=("Medium") I5=matrix(cell8)

tab F5D1r
tab F5D1r, matcell(cell9)
putexcel J4=("Dark") J5=matrix(cell9)



putexcel B11=("Question 2")

tab F1L2r
tab F1L2r, matcell(cell10)
putexcel B13=("Light") B14=matrix(cell10)
putexcel A14=("Very unlikely") A15=("Somewhat unlikely") A16=("Neutral") ///
	A17=("Somewhat likely") A18=("Very likely")
	
putexcel C12=("Woman 1")	

tab F1M2r
tab F1M2r, matcell(cell11)
putexcel C13=("Medium") C14=matrix(cell11)

tab F1D2r
tab F1D2r,  matcell(cell12)
putexcel D13=("Dark") D14=matrix(cell12)

tab F3L2r
tab F3L2r, matcell(cell13)
putexcel E13=("Light") E14=matrix(cell13)

putexcel F12=("Woman 2")

tab F3M2r
tab F3M2r, matcell(cell14)
putexcel F13=("Medium") F14=matrix(cell14)

tab F3D2r
tab F3D2r, matcell(cell15)
putexcel G13=("Dark") G14=matrix(cell15)

tab F5L2r
tab F5L2r, matcell(cell16)
putexcel H13=("Light") H14=matrix(cell16)

putexcel I12=("Woman 3")

tab F5M2r
tab F5M2r, matcell(cell17)
putexcel I13=("Medium") I14=matrix(cell17)

tab F5D2r
tab F5D2r, matcell(cell18)
putexcel J13=("Dark") J14=matrix(cell18)



putexcel B20=("Question 3")

tab F1L3r
tab F1L3r, matcell(cell19)
putexcel B22=("Light") B23=matrix(cell19)
putexcel A23=("Very unlikely") A24=("Somewhat unlikely") A25=("Neutral") ///
	A26=("Somewhat likely") A27=("Very likely")

putexcel C21=("Woman 1")	

tab F1M3r
tab F1M3r, matcell(cell20)
putexcel C22=("Medium") C23=matrix(cell20)	

tab F1D3r
tab F1D3r, matcell(cell21)
putexcel D22=("Dark") D23=matrix(cell21)

tab F3L3r
tab F3L3r, matcell(cell22)
putexcel E22=("Light") E23=matrix(cell22)

putexcel F21=("Woman 2")

tab F3M3r
tab F3M3r, matcell(cell23)
putexcel F22=("Medium") F23=matrix(cell23)

tab F3D3r
tab F3D3r, matcell(cell24)
putexcel G22=("Dark") G23=matrix(cell24)

tab F5L3r
tab F5L3r, matcell(cell25)
putexcel H22=("Light") H23=matrix(cell25)

putexcel I21=("Woman 3")

tab F5M3r
tab F5M3r, matcell(cell26)
putexcel I22=("Medium") I23=matrix(cell26)

tab F5D3r
tab F5D3r, matcell(cell27)
putexcel J22=("Dark") J23=matrix(cell27)




putexcel L1=("Ratings by Person, Shade, and Question (Men)")
putexcel M2=("Question 1")

tab M3L1r
tab M3L1r, matcell(cell28)
putexcel N3=("Man 1")
putexcel M4=("Light") M5=matrix(cell28)
putexcel L5=("Very unlikely") L6=("Somewhat unlikely") L7=("Neutral") ///
	L8=("Somewhatlikely") L9=("Very likely")

tab M3M1r
tab M3M1r, matcell(cell29)
putexcel N4=("Medium") N5=matrix(cell29)

tab M3D1r
tab M3D1r, matcell(cell30)
putexcel O4=("Dark") O5=matrix(cell30)

putexcel Q3=("Man 2")

tab M5L1r
tab M5L1r, matcell(cell31)
putexcel P4=("Light") P5=matrix(cell31)

tab M5M1r
tab M5M1r, matcell(cell32)
putexcel Q4=("Medium") Q5=matrix(cell32)

tab M5D1r
tab M5D1r, matcell(cell33)
putexcel R4=("Dark") R5=matrix(cell33)

tab M6L1r
tab M6L1r, matcell(cell34)
putexcel S4=("Light") S5=matrix(cell34)

putexcel T3=("Man 3")

tab M6M1r
tab M6M1r, matcell(cell35)
putexcel T4=("Medium") T5=matrix(cell35)

tab M6D1r
tab M6D1r, matcell(cell36)
putexcel U4=("Dark") U5=matrix(cell36)




putexcel M11=("Question 2")

tab M3L2r
tab M3L2r, matcell(cell37)
putexcel N12=("Man 1")
putexcel M13=("Light") M14=matrix(cell37)
putexcel L14=("Very unlikely") L15=("Somewhat unlikely") L16=("Neutral") ///
	L17=("Somewhatlikely") L18=("Very likely")

tab M3M2r
tab M3M2r, matcell(cell38)
putexcel N13=("Medium") N14=matrix(cell38)

tab M3D2r
tab M3D2r, matcell(cell39)
putexcel O13=("Dark") O14=matrix(cell39)

tab M5L2r
tab M5L2r, matcell(cell40)
putexcel P13=("Light") P14=matrix(cell40)

putexcel Q12=("Man 2")

tab M5M2r
tab M5M2r, matcell(cell41)
putexcel Q13=("Medium") Q14=matrix(cell41)

tab M5D2r
tab M5D2r, matcell(cell42)
putexcel R13=("Dark") R14=matrix(cell42)

tab M6L2r
tab M6L2r, matcell(cell43)
putexcel S13=("Light") S14=matrix(cell43)

putexcel T12=("Man 3")

tab M6M2r
tab M6M2r, matcell(cell44)
putexcel T13=("Medium") T14=matrix(cell44)

tab M6D2r
tab M6D2r, matcell(cell45)
putexcel U13=("Dark") U14=matrix(cell45)




putexcel M20=("Question 3")

tab M3L3r
tab M3L3r, matcell(cell46)
putexcel N21=("Man 1")
putexcel M22=("Light") M23=matrix(cell46)
putexcel L23=("Very unlikely") L24=("Somewhat unlikely") L25=("Neutral") ///
	L26=("Somewhatlikely") L27=("Very likely")

tab M3M3r
tab M3M3r, matcell(cell47)
putexcel N22=("Medium") N23=matrix(cell47)

tab M3D3r
tab M3D3r, matcell(cell48)
putexcel O22=("Dark") O23=matrix(cell48)

tab M5L3r
tab M5L3r, matcell(cell49)
putexcel P22=("Light") P23=matrix(cell49)

putexcel Q21=("Man 2")

tab M5M3r
tab M5M3r, matcell(cell50)
putexcel Q22=("Medium") Q23=matrix(cell50)

tab M5D3r
tab M5D3r, matcell(cell51)
putexcel R22=("Dark") R23=matrix(cell51)

tab M6L3r
tab M6L3r, matcell(cell52)
putexcel S22=("Light") S23=matrix(cell52)

putexcel T21=("Man 3")

tab M6M3r
tab M6M3r, matcell(cell53)
putexcel T22=("Medium") T23=matrix(cell53)

tab M6D3r
tab M6D3r, matcell(cell54)
putexcel U22=("Dark") U23=matrix(cell54)



expand 6
bysort case_id: gen n = _n
tab n, mi

forval i = 1/3 {
gen q`i' = 0
replace q`i' = F1L`i' if F1L`i' != . & n == 1
replace q`i' = F1M`i' if F1M`i' != . & n == 1
replace q`i' = F1D`i' if F1D`i' != . & n == 1
tab F1L`i' q`i' if n==1, mi
tab F1M`i' q`i' if n==1, mi
tab F1D`i' q`i' if n==1, mi

replace q`i' = F3L`i' if F3L`i' != . & n == 2
replace q`i' = F3M`i' if F3M`i' != . & n == 2
replace q`i' = F3D`i' if F3D`i' != . & n == 2
tab F3L`i' q`i' if n==2, mi
tab F3M`i' q`i' if n==2, mi
tab F3D`i' q`i' if n==2, mi

replace q`i' = F5L`i' if F5L`i' != . & n == 3
replace q`i' = F5M`i' if F5M`i' != . & n == 3
replace q`i' = F5D`i' if F5D`i' != . & n == 3
tab F5L`i' q`i' if n==3, mi
tab F5M`i' q`i' if n==3, mi
tab F5D`i' q`i' if n==3, mi

replace q`i' = M3L`i' if M3L`i' != . & n == 4
replace q`i' = M3M`i' if M3M`i' != . & n == 4
replace q`i' = M3D`i' if M3D`i' != . & n == 4
tab M3L`i' q`i' if n==4, mi
tab M3M`i' q`i' if n==4, mi
tab M3D`i' q`i' if n==4, mi

replace q`i' = M5L`i' if M5L`i' != . & n == 5
replace q`i' = M5M`i' if M5M`i' != . & n == 5
replace q`i' = M5D`i' if M5D`i' != . & n == 5
tab M5L`i' q`i' if n==5, mi
tab M5M`i' q`i' if n==5, mi
tab M5D`i' q`i' if n==5, mi

replace q`i' = M6L`i' if M6L`i' != . & n == 6
replace q`i' = M6M`i' if M6M`i' != . & n == 6
replace q`i' = M6D`i' if M6D`i' != . & n == 6
tab M6L`i' q`i' if n==6, mi
tab M6M`i' q`i' if n==6, mi
tab M6D`i' q`i' if n==6, mi

tab q`i', mi
replace q`i' = . if q`i' == 0
tab q`i', mi

}

gen light = 0
replace light = 1 if (F1L1 != . | F1L2 != . | F1L3 != .) & n == 1
replace light = 1 if (F3L1 != . | F3L2 != . | F3L3 != .) & n == 2
replace light = 1 if (F5L1 != . | F5L2 != . | F5L3 != .) & n == 3
replace light = 1 if (M3L1 != . | M3L2 != . | M3L3 != .) & n == 4
replace light = 1 if (M5L1 != . | M5L2 != . | M5L3 != .) & n == 5
replace light = 1 if (M6L1 != . | M6L2 != . | M6L3 != .) & n == 6

tab light, mi

gen med = 0
replace med = 1 if (F1M1 != . | F1M2 != . | F1M3 != .) & n == 1
replace med = 1 if (F3M1 != . | F3M2 != . | F3M3 != .) & n == 2
replace med = 1 if (F5M1 != . | F5M2 != . | F5M3 != .) & n == 3
replace med = 1 if (M3M1 != . | M3M2 != . | M3M3 != .) & n == 4
replace med = 1 if (M5M1 != . | M5M2 != . | M5M3 != .) & n == 5
replace med = 1 if (M6M1 != . | M6M2 != . | M6M3 != .) & n == 6

tab med, mi

gen dark = 0
replace dark = 1 if (F1D1 != . | F1D2 != . | F1D3 != .) & n == 1
replace dark = 1 if (F3D1 != . | F3D2 != . | F3D3 != .) & n == 2
replace dark = 1 if (F5D1 != . | F5D2 != . | F5D3 != .) & n == 3 
replace dark = 1 if (M3D1 != . | M3D2 != . | M3D3 != .) & n == 4
replace dark = 1 if (M5D1 != . | M5D2 != . | M5D3 != .) & n == 5
replace dark = 1 if (M6D1 != . | M6D2 != . | M6D3 != .) & n == 6

tab dark, mi

bigtab light med dark

list q1 F1L1 F1M1 F1D1 F3L1 F3M1 F3D1 light dark med n in 1/300

gen sc2 = 6
replace sc2 = 0 if light == 1
replace sc2 = 1 if med == 1
replace sc2 = 2 if dark == 1
replace sc2 = . if sc2 == 6
label define sc2 0 "Light" 1 "Medium" 2 "Dark"
label values sc2 sc2
tab sc2 light, mi
tab sc2 med, mi
tab sc2 dark, mi


gen q1r = 6-q1 
gen q2r = 6-q2
gen q3r = 6-q3
tab q1r q1, mi
tab q2r q2, mi
tab q3r q3, mi


recode n (1=0) (2=1) (3=2) (4=3) (5=4) (6=5), gen(newn)
gen wn = .
replace wn = 0 if n == 1
replace wn = 1 if n == 2
replace wn = 2 if n == 3

gen mn = .
replace mn = 0 if n == 4
replace mn = 1 if n == 5
replace mn = 2 if n == 6

tab wn newn, mi
tab mn newn, mi

tab sc2, generate(sc2)
tab newn, generate(newnd)
tab mn, generate(mnd)
tab wn, generate(wnd)



meologit q1r sc22 sc23 newnd2-newnd6 || case_id:, vce(cluster case_id) 
est sto b1
meologit q2r sc22 sc23 newnd2-newnd6 || case_id:, vce(cluster case_id) 
est sto b2
meologit q3r sc22 sc23 newnd2-newnd6|| case_id:, vce(cluster case_id)
est sto b3

meologit q1r sc21 sc23 newnd2-newnd6 || case_id:, vce(cluster case_id) 
est sto b4
meologit q2r sc21 sc23 newnd2-newnd6|| case_id:, vce(cluster case_id) 
est sto b5
meologit q3r sc21 sc23 newnd2-newnd6 || case_id:, vce(cluster case_id)
est sto b6


meologit q1r sc22 sc23 wnd2 wnd3 || case_id:, vce(cluster case_id) 
est sto b7
meologit q2r sc22 sc23 wnd2 wnd3 || case_id:, vce(cluster case_id) 
est sto b8
meologit q3r sc22 sc23 wnd2 wnd3 || case_id:, vce(cluster case_id)
est sto b9

meologit q1r sc21 sc23 wnd2 wnd3 || case_id:, vce(cluster case_id) 
est sto b10
meologit q2r sc21 sc23 wnd2 wnd3 || case_id:, vce(cluster case_id) 
est sto b11
meologit q3r sc21 sc23 wnd2 wnd3 || case_id:, vce(cluster case_id)
est sto b12

meologit q1r sc22 sc23 mnd2 mnd3 || case_id:, vce(cluster case_id) 
est sto b13
meologit q2r sc22 sc23 mnd2 mnd3 || case_id:, vce(cluster case_id) 
est sto b14
meologit q3r sc22 sc23 mnd2 mnd3 || case_id:, vce(cluster case_id)
est sto b15

meologit q1r sc21 sc23 mnd2 mnd3 || case_id:, vce(cluster case_id) 
est sto b16
meologit q2r sc21 sc23 mnd2 mnd3 || case_id:, vce(cluster case_id) 
est sto b17
meologit q3r sc21 sc23 mnd2 mnd3 || case_id:, vce(cluster case_id)
est sto b18


esttab b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 b16 b17 b18 ///
using "scemainanalyses050324.csv", se pr2 star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace




meologit q1r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(1)) at (sc2=(0 1 2)) post
est sto b1

meologit q1r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(2)) at (sc2=(0 1 2)) post
est sto b2

meologit q1r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(3)) at (sc2=(0 1 2)) post
est sto b3

meologit q1r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(4)) at (sc2=(0 1 2)) post
est sto b4

meologit q1r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(5)) at (sc2=(0 1 2)) post
est sto b5

esttab b1 b2 b3 b4 b5 using "scepredictedprobabilitiesq1ver2050324.csv", nostar not nolines noobs replace


meologit q2r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(1)) at (sc2=(0 1 2)) post
est sto b1

meologit q2r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(2)) at (sc2=(0 1 2)) post
est sto b2

meologit q2r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(3)) at (sc2=(0 1 2)) post
est sto b3

meologit q2r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(4)) at (sc2=(0 1 2)) post
est sto b4

meologit q2r i.sc2 i.newn || case_id:, vce(cluster case_id) 
margins, predict(outcome(5)) at (sc2=(0 1 2)) post
est sto b5

esttab b1 b2 b3 b4 b5 using "scepredictedprobabilitiesq2ver2050324.csv", nostar not nolines noobs replace



meologit q3r i.sc2 i.newn || case_id:, vce(cluster case_id)
margins, predict(outcome(1)) at (sc2=(0 1 2)) post
est sto b1

meologit q3r i.sc2 i.newn || case_id:, vce(cluster case_id)
margins, predict(outcome(2)) at (sc2=(0 1 2)) post
est sto b2

meologit q3r i.sc2 i.newn || case_id:, vce(cluster case_id)
margins, predict(outcome(3)) at (sc2=(0 1 2)) post
est sto b3

meologit q3r i.sc2 i.newn || case_id:, vce(cluster case_id)
margins, predict(outcome(4)) at (sc2=(0 1 2)) post
est sto b4

meologit q3r i.sc2 i.newn || case_id:, vce(cluster case_id)
margins, predict(outcome(5)) at (sc2=(0 1 2)) post
est sto b5

esttab b1 b2 b3 b4 b5 using "scepredictedprobabilitiesq3ver3050324.csv", nostar not nolines noobs replace



clear
